Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

VACMS-14752: Adds check all (mixed state) field formatter for checkbox widgets.#21046

Open
dsasser wants to merge 23 commits into
mainfrom
VACMS-14752-add-check-all-option-for-checkbox-widgets
Open

VACMS-14752: Adds check all (mixed state) field formatter for checkbox widgets.#21046
dsasser wants to merge 23 commits into
mainfrom
VACMS-14752-add-check-all-option-for-checkbox-widgets

Conversation

@dsasser
Copy link
Copy Markdown
Contributor

@dsasser dsasser commented Mar 31, 2025

Description

Relates to #14752

This PR creates a new field formatter (for multi-value boolean fields (checkboxes) that adds a 'select all' option. Created as a field widget to be usable across the system. This implementation detail was chosen in order to avoid bespoke code for a single use case.

Why not an existing Drupal module? See here.

The 'select all' formatter implements a 'checkbox mixed/tri-state' variant that includes checked, unchecked, and mixed states. The mixed state is represented visually and with ARIA attributes for accessibility.

The formatter allows for custom for 'select all' text such that each field can have a contextual value. (see screenshot below for VAMC System Banner Alert with Situation Updates).

The javascript for the formatter was modified from W3.org. License is GPL compatible so we are good to use and modify providing we include the license info, which was added to the new checkbox_mix library per Drupal standards.

Generated description

This pull request includes several changes to enhance the functionality and styling of checkboxes in the va_gov_backend module. The most significant changes involve adding a new "select mixed options" checkbox behavior, updating related JavaScript files, and modifying the backend to support these changes.

Enhancements to checkbox functionality:

Backend support for new checkbox behavior:

Styling updates:

Configuration updates:

Testing done

Tested in a VAMC System Banner Alert with Situation Updates content type manually using both mouse and keyboard functionality (for accessibility).
Verified the GraphQL query results in no structural changes or additional data. [proof tbd]

Screenshots

Screenshot 2025-03-31 at 9 14 42 AM Screenshot 2025-03-31 at 9 18 42 AM Screenshot 2025-03-31 at 9 18 34 AM

QA steps

As an admin...

  • Visit the form display page for the VAMC System Banner with Situation Updates content type.
  • Validate the 'Pages for the following VAMC systems' has the 'Checkbox/radio buttons with select all' field widget selected.
  • Validate the summary text is: "Select all text: Select all VAMC systems"

Validate Existing VAMC Banner with Situation Updates Form:

  • Edit this existing VAMC banner (from the issue description as a candidate example).
  • Validate you see the 'Select all VAMC systems option'.
  • Validate that not all the current VAMCs are selected.
  • Validate that the 'Select all VAMC systems option' checkbox is in the "mixed" state (has an 'X' to identify not all options are selected, and that all options are not unselected...a mixed state.
  • Click on the 'Select all VAMC systems option' checkbox.
  • Validate that all options become selected.
  • Validate that the 'Select all VAMC systems option' becomes selected (shows a checkmark)
  • Click again on the 'Select all VAMC systems option' checkbox.
  • Validate that all VAMC options are unselected.
  • Validate that the 'Select all VAMC systems option' become unselected (shows an empty checkbox)
  • Click a third time on the 'Select all VAMC systems option' checkbox
  • Validate you return to the previous mixed state (checkbox states as originally found when loading the page)
  • Validate that the 'Select all VAMC systems option' checkbox is in the "mixed" state (an X in the checkbox to distinguish mixed state)

Validate New VAMC Banner with Situation Updates Form:

  • Visit the 'create new' VAMC Banner with Situation Updates node page
  • Validate the 'Select all VAMC systems' exists and is in the deselected state.
  • Select the 'Select all VAMC systems' option.
  • Validate all VAMC system checkboxes get selected/checked.
  • Fill out all required fields and save the node as not published.
  • On the node view page
  • Validate all 141 VAMCs are listed. To do so, open devtools, and run the following javascript in the 'console' document.querySelectorAll('.field--name-field-banner-alert-vamcs .field__item').length

Definition of Done

  • Documentation has been updated, if applicable.
  • Tests have been added if necessary.
  • Automated tests have passed.
  • Code Quality Tests have passed.
  • Acceptance Criteria in related issue are met.
  • Manual Code Review Approved.
  • If there are field changes, front end output has been thoroughly checked.

Select Team for PR review

  • CMS Team
  • Public websites
  • Facilities
  • User support
  • Accelerated Publishing

@dsasser dsasser requested review from a team as code owners March 31, 2025 16:25
@va-cms-bot va-cms-bot temporarily deployed to Tugboat March 31, 2025 16:25 Destroyed
@github-actions
Copy link
Copy Markdown

Checking composer.lock changes...

Comment thread docroot/modules/custom/va_gov_backend/js/checkbox_mixed.es6.js
@github-actions github-actions Bot added the Facilities Facilities products (VAMC, Vet Center, etc) label Mar 31, 2025
@va-cms-bot va-cms-bot temporarily deployed to Tugboat March 31, 2025 17:34 Destroyed
@github-actions
Copy link
Copy Markdown

Checking composer.lock changes...

@va-cms-bot va-cms-bot temporarily deployed to Tugboat March 31, 2025 18:58 Destroyed
@github-actions
Copy link
Copy Markdown

Checking composer.lock changes...

@dsasser
Copy link
Copy Markdown
Contributor Author

dsasser commented Apr 1, 2025

Getting this error when editing this node, that is not occurring on my local:

Error: Call to a member function bundle() on null in va_gov_backend_field_widget_single_element_paragraphs_form_alter() (line 1085 of modules/custom/va_gov_backend/va_gov_backend.module)

Pulling in a fresh db locally to see if I can replicate.

  • edit -

I could not reproduce this locally with the same db as TB. I added a simple bail out conditional in va_gov_backend_field_widget_single_element_paragraphs_form_alter() if the paragraph couldn't be found. That would be an extremely odd situation, since this function is only called during paragraph widget forms are built, but a safeguard doesn't hurt.

@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 1, 2025 02:17 Destroyed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2025

Checking composer.lock changes...

@dsasser
Copy link
Copy Markdown
Contributor Author

dsasser commented Apr 1, 2025

Getting this error when editing this node, that is not occurring on my local:

Error: Call to a member function bundle() on null in va_gov_backend_field_widget_single_element_paragraphs_form_alter() (line 1085 of modules/custom/va_gov_backend/va_gov_backend.module)

Pulling in a fresh db locally to see if I can replicate.

  • edit -

I could not reproduce this locally with the same db as TB. I added a simple bail out conditional in va_gov_backend_field_widget_single_element_paragraphs_form_alter() if the paragraph couldn't be found. That would be an extremely odd situation, since this function is only called during paragraph widget forms are built, but a safeguard doesn't hurt.

This commit has resolved the problem.

@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 22, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 23, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 24, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 25, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 26, 2025 08:09 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 27, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 28, 2025 08:07 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 29, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat April 30, 2025 08:07 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 1, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 2, 2025 08:07 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 3, 2025 08:09 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 4, 2025 08:09 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 5, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 6, 2025 08:09 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 7, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 8, 2025 08:09 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 9, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 10, 2025 08:09 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 11, 2025 08:08 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 12, 2025 08:10 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 13, 2025 08:10 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 14, 2025 08:09 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 15, 2025 08:09 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 16, 2025 08:10 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 17, 2025 08:09 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 18, 2025 08:10 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 19, 2025 08:11 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 20, 2025 08:10 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat May 21, 2025 08:09 Destroyed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DO NOT MERGE Do not merge this PR Facilities Facilities products (VAMC, Vet Center, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants